home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-10-05 | 3.6 KB | 191 lines | [TEXT/MMCC] |
- // CAMReminderData.cp -- document data
- // Created 10/5/95 4:49 PM by AppMaker
-
- // The purpose of the Data module is to shield the rest of your application
- // from your internal data structures and the representation of your files.
- // The Data module provides an abstract interface to the contents of your files.
-
- #include "CAMReminderData.h"
-
- #include <LFileStream.h>
-
- //----------
- // initialize application data
-
- void CAMReminderData::InitAppData()
- {
- }
-
- // ---------------------------------------------------------------------------
- // • CAMReminderData
- // ---------------------------------------------------------------------------
-
- CAMReminderData::CAMReminderData()
- :LBroadcaster()
- {
- mFile = nil;
- mDirty = false;
- }
-
- // ---------------------------------------------------------------------------
- // • ~CAMReminderData
- // ---------------------------------------------------------------------------
- // Destructor
- //
-
- CAMReminderData::~CAMReminderData()
- {
- CloseFile();
- }
-
- //----------
- void CAMReminderData::newData()
- {
- CreateData();
- initDocData();
- }
-
- //----------
- void CAMReminderData::openData (FSSpec *inMacFSSpec)
- {
- mFile = OpenFile (inMacFSSpec);
- initDocData();
- ReadData();
- }
-
- //----------
- void CAMReminderData::initDocData()
- {
- }
-
- //----------
- Boolean CAMReminderData::IsDirty()
- {
- return mDirty;
- }
-
- //----------
- void CAMReminderData::DoSave()
- {
- WriteData(mFile);
- }
-
- //----------
- void CAMReminderData::DoSaveAs (FSSpec *inMacFSSpec)
- {
- LFileStream *file;
-
- file = CreateFile(inMacFSSpec);
- if (file != nil) {
- WriteData(file);
- CloseFile(); // old file
- mFile = file;
- }
- }
-
- //----------
- void CAMReminderData::DoRevert()
- {
- DisposeData();
- if (mFile != nil) {
- ReadData();
- }
- }
-
- //----------
- void CAMReminderData::CloseFile()
- {
- if (mFile != nil) {
- delete mFile;
- mFile = nil;
- }
- }
-
- //----------
- // CreateFile is called in two situations:
- // 1. To Save a new untitled document
- // 2. To SaveAs to a new file
-
- LFileStream *CAMReminderData::CreateFile (FSSpec *inMacFSSpec)
- {
- LFileStream *file = new LFileStream(*inMacFSSpec);
-
- file->CreateNewDataFile(kSignature, kFileType);
- file->OpenDataFork(fsRdWrPerm);
-
- return file;
- }
-
- //----------
- LFileStream *CAMReminderData::OpenFile (FSSpec *inMacFSSpec)
- {
- LFileStream *file = new LFileStream(*inMacFSSpec);
-
- file->OpenDataFork(fsRdWrPerm);
-
- return file;
- }
-
- // The next few methods are for transferring data between the
- // data file and your internal data structures, and for disposing
- // your data structures. They are called by Open, Close, etc.
- // Replace their bodies with whatever is suitable for your application
-
- // define internal data structures to describe the file format:
-
- //----------
- typedef struct
- {
- int stuff;
-
- } AMReminderData;
-
- //----------
- void CAMReminderData::CreateData()
- {
- // initialize your data structures
- }
-
- //----------
- void CAMReminderData::DisposeData()
- {
- // delete your data structures
-
- mDirty = false;
- }
-
- //----------
- void CAMReminderData::ReadData()
- {
- // read all or part of the file into your data structures
- }
-
- //----------
- // WriteData is called in two situations:
- // 1. To Save the current document
- // 2. To SaveAs to a new file
-
- void CAMReminderData::WriteData (LFileStream *file)
- {
- // write from your data structures to the file
-
- mDirty = false;
- }
-
- // The remaining methods are for accessing your data as logical chunks.
- // These are just models for your own accessor functions;
- // they aren't called by any AppMaker-generated code.
- // Replace them with whatever is suitable for your application.
-
- //----------
- void CAMReminderData::GetStuff (void* stuff)
- {
- }
-
- //----------
- void CAMReminderData::SetStuff (void* stuff)
- {
- }
-
- // AMReminderData.cp
-